package com.chat.http.service;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.chat.dao.ICertificateDao;
import com.chat.entity.TdChatCertificate;

@Service
public class PlanConnectionService {

	@Autowired
	private ICertificateDao certificateDao;

	/**
	 * 切入事务，只读，异常回滚
	 * 
	 * @return
	 */
	@Transactional(readOnly = true, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public boolean valiatorCertificate(Integer type, String accesskey, String secretkey) {
		TdChatCertificate temp = new TdChatCertificate(type, accesskey, secretkey);
		Map<String, String> map = certificateDao.selectCertificateKeys( temp );
		//参数(type, accesskey, secretkey)在controller控制不能为空，如果能查询到符合条件的则map不为空，反之为空
		if (map != null ) {
			return true;
		}
		return false;
	}
}
